package palmer;

import java.awt.*;
import java.util.Random;


public class GrafischerWuerfel extends Canvas {

	private Random r;
	private int dimensionCanvas;
	private int dimensionAuge;
	private int augen;
	
	public GrafischerWuerfel(int xPos, int yPos, int seite) {
		super();
		this.setBounds(xPos, yPos, seite, seite);
		this.setBackground(Color.BLUE);
		
		dimensionCanvas=seite;
		dimensionAuge=dimensionCanvas/10;
		r=new Random();
	}
	
	public void paint(Graphics g) {
		augen = zufallszahl();
		System.out.println(augen);
		g.setColor(Color.WHITE);
		
		switch (augen){
		case 1: g.fillOval(dimensionCanvas/2-dimensionAuge/2,
					dimensionCanvas/2-dimensionAuge/2, dimensionAuge, dimensionAuge);
		break;
		
		case 3:	g.fillOval(dimensionCanvas/2-dimensionAuge/2,
					dimensionCanvas/2-dimensionAuge/2, dimensionAuge, dimensionAuge);
				
				g.fillOval(dimensionAuge*2-dimensionAuge/2,dimensionAuge*2-dimensionAuge/2, 
						dimensionAuge, dimensionAuge);
				g.fillOval(dimensionCanvas-2*dimensionAuge-dimensionAuge/2, 
					dimensionCanvas-2*dimensionAuge-dimensionAuge/2, dimensionAuge, dimensionAuge);
		break;
				
		case 5: g.fillOval(dimensionCanvas/2-dimensionAuge/2,
					dimensionCanvas/2-dimensionAuge/2, dimensionAuge, dimensionAuge);
		
		case 4:	g.fillOval(dimensionAuge*2-dimensionAuge/2,dimensionCanvas-2*dimensionAuge-dimensionAuge/2, 
					dimensionAuge, dimensionAuge);
				g.fillOval(dimensionCanvas-2*dimensionAuge-dimensionAuge/2, 
					dimensionAuge*2-dimensionAuge/2, dimensionAuge, dimensionAuge);
					
		case 2: g.fillOval(dimensionAuge*2-dimensionAuge/2,dimensionAuge*2-dimensionAuge/2, 
					dimensionAuge, dimensionAuge);
				g.fillOval(dimensionCanvas-2*dimensionAuge-dimensionAuge/2, 
					dimensionCanvas-2*dimensionAuge-dimensionAuge/2, dimensionAuge, dimensionAuge);
		break;
		
		case 6:	g.fillOval(dimensionAuge*2-dimensionAuge/2,dimensionAuge*2-dimensionAuge/2, 
					dimensionAuge, dimensionAuge);
				g.fillOval(dimensionCanvas-2*dimensionAuge-dimensionAuge/2, 
						dimensionCanvas-2*dimensionAuge-dimensionAuge/2, dimensionAuge, dimensionAuge);

				g.fillOval(dimensionAuge*2-dimensionAuge/2,dimensionCanvas-2*dimensionAuge-dimensionAuge/2, 
						dimensionAuge, dimensionAuge);
				g.fillOval(dimensionCanvas-2*dimensionAuge-dimensionAuge/2, 
					dimensionAuge*2-dimensionAuge/2, dimensionAuge, dimensionAuge);
				
				g.fillOval(dimensionAuge*2-dimensionAuge/2, dimensionCanvas/2-dimensionAuge/2, 
						dimensionAuge, dimensionAuge);
				g.fillOval(dimensionCanvas-2*dimensionAuge-dimensionAuge/2, dimensionCanvas/2-dimensionAuge/2, 
						dimensionAuge, dimensionAuge);
		}
	}
	
	public int gibWert(){
		return augen;
	}
	
	
	private int zufallszahl() {
		int zufall=r.nextInt(6)+1;
		return zufall;
	}
}
